# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaConnectorRunEntityRun do
  @moduledoc """
  Represents an entity that was synced in this ConnectorRun.

  ## Attributes

  *   `deletedRecordCount` (*type:* `String.t`, *default:* `nil`) - The number of documents deleted.
  *   `entityName` (*type:* `String.t`, *default:* `nil`) - The name of the source entity.
  *   `errorRecordCount` (*type:* `String.t`, *default:* `nil`) - The total number of documents failed at sync at any stage (extraction, indexing, etc).
  *   `errors` (*type:* `list(GoogleApi.DiscoveryEngine.V1beta.Model.GoogleRpcStatus.t)`, *default:* `nil`) - The errors from the entity's sync run. Only exist if running into an error state. Contains error code and error message.
  *   `extractedRecordCount` (*type:* `String.t`, *default:* `nil`) - The number of documents extracted from connector source, ready to be ingested to UCS.
  *   `indexedRecordCount` (*type:* `String.t`, *default:* `nil`) - The number of documents indexed.
  *   `progress` (*type:* `GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaConnectorRunEntityRunProgress.t`, *default:* `nil`) - Metadata to generate the progress bar.
  *   `sourceApiRequestCount` (*type:* `String.t`, *default:* `nil`) - The number of requests sent to 3p API.
  *   `state` (*type:* `String.t`, *default:* `nil`) - The state of the entity's sync run.
  *   `stateUpdateTime` (*type:* `DateTime.t`, *default:* `nil`) - Timestamp at which the entity sync state was last updated.
  *   `statsUpdateTime` (*type:* `DateTime.t`, *default:* `nil`) - The timestamp for either extracted_documents_count, indexed_documents_count and error_documents_count was last updated.
  *   `syncType` (*type:* `String.t`, *default:* `nil`) - Sync type of this run.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :deletedRecordCount => String.t() | nil,
          :entityName => String.t() | nil,
          :errorRecordCount => String.t() | nil,
          :errors => list(GoogleApi.DiscoveryEngine.V1beta.Model.GoogleRpcStatus.t()) | nil,
          :extractedRecordCount => String.t() | nil,
          :indexedRecordCount => String.t() | nil,
          :progress =>
            GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaConnectorRunEntityRunProgress.t()
            | nil,
          :sourceApiRequestCount => String.t() | nil,
          :state => String.t() | nil,
          :stateUpdateTime => DateTime.t() | nil,
          :statsUpdateTime => DateTime.t() | nil,
          :syncType => String.t() | nil
        }

  field(:deletedRecordCount)
  field(:entityName)
  field(:errorRecordCount)
  field(:errors, as: GoogleApi.DiscoveryEngine.V1beta.Model.GoogleRpcStatus, type: :list)
  field(:extractedRecordCount)
  field(:indexedRecordCount)

  field(:progress,
    as:
      GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaConnectorRunEntityRunProgress
  )

  field(:sourceApiRequestCount)
  field(:state)
  field(:stateUpdateTime, as: DateTime)
  field(:statsUpdateTime, as: DateTime)
  field(:syncType)
end

defimpl Poison.Decoder,
  for:
    GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaConnectorRunEntityRun do
  def decode(value, options) do
    GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaConnectorRunEntityRun.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for:
    GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaConnectorRunEntityRun do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
